<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ page import="java.util.Locale" %>
<%@ page import="com.nexfra.bbssys.common.Constants,com.nexfra.bbssys.common.domain.User,com.nexfra.bbssys.common.utils.SessionUtil" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core' %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%
    /**
     * @Description : commonJs
     * @Modification Information
     *
     *   수정일               수정자                   수정내용
     *  -------    --------    ---------------------------
     *
     *
     */
%>
<script type="text/javascript" src="<c:url value='/resources/js/common/common.js'/>"></script>
<script type="text/javascript" src="<c:url value='/resources/js/common/form.js'/>"></script>
<script type="text/javascript" >
/**
 * 공통코드 조회
 * 사용예)
 * var options = {
 *         data:'testId=001&testName=name',     //required
 *         async:false                          //optional
 *         success:succesFnc,                   //optional
 *         error:failFnc                        //optional
 *         append:false                         //optional default:false 행추가플래그(0번째인덱스에 '선택'row 추가여부)
 *         selected:selectedValue               //optional select박스옵션 선택값
 * };
 * ajaxCommonCode(options);
 */
var ajaxCommonCode = function(options) {
    $.ajax({
        type : "post",
        url : "<c:url value="/common/selectCommonCode"/>",
        async: options.async || true,
        dataType: "json",
        data : {cd_class: options.data},
        success : function(data, state) {
            /*console.log("--- callback success ---");
            console.log("data: " + data);
            console.log("state: " + state);
            */
            console.log("data---------------------------")
            console.log(data);
            options.success ? options.success(data, state) : respCodeSelect(options.selector, data, state, options.append, options.selectedValue);
        },
        error : function(xhr, status, error) {
            console.log("--- callback error ---");
            
            var data = JSON.parse(xhr.responseText);
            if(data.errorCode == -1) {
                alert("작업중 오류가 발생하였습니다. \n message:"+data.errorMessage);
            } 

            options.error ? options.error(xhr, status, error) : '';
        },
    });
};
</script>  